package com.chenjt.jvm.first.ten_GC;

/**
 * 注释：
 * 强引用测试
 *
 * @author chenjt
 * @date 2025/6/17 8:56
 */
public class StrongReferenceTest {

    public static void main(String[] args) {
        StringBuffer str = new StringBuffer("hello");
        StringBuffer str1 = str;

        // 置空str的引用，但是str1的引用未置空
        str = null;
        System.gc();

        try {
            // 确保gc已启动
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(str1);
    }


}
